From 07443ee6da5827ee23e8ff6bae895166ee81e581 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 2 Dec 2009 08:45:16 +0000 Subject: [PATCH] libxenlight: write stubdoms logs to file It turns out that there is a better way to write stubdoms logs to file than using libxl_console_attach: qemu is the one that provides the console backend for stubdoms and qemu is able to redirect a serial to file, so we can use this feature to make sure the first stubdom console is always redirected to a logfile. Signed-off-by: Stefano Stabellini --- tools/libxl/libxl.c | 11 ++++++++++- tools/libxl/libxl_utils.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 858c17052e..8d4411f613 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1352,7 +1352,16 @@ static int libxl_build_xenpv_qemu_args(struct libxl_ctx *ctx, num++; } if (num > 0) { - info->serial = "pty"; + uint32_t guest_domid = libxl_is_stubdom(ctx, vfb->domid); + if (guest_domid) { + char *filename; + char *name = libxl_sprintf(ctx, "qemu-dm-%s", libxl_domid_to_name(ctx, guest_domid)); + libxl_create_logfile(ctx, name, &filename); + info->serial = libxl_sprintf(ctx, "file:%s", filename); + free(filename); + } else { + info->serial = "pty"; + } num--; } if (num > 0) { diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 4a8f44f814..3d731ce029 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -185,7 +185,7 @@ int libxl_is_stubdom(struct libxl_ctx *ctx, int domid) { char *target = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/target", libxl_xs_get_dompath(ctx, domid))); if (target) - return 1; + return atoi(target); else return 0; } -- 2.30.2